using System;
using System.Xml.Serialization;
using Microsoft.Xna.Framework;
using Core.Graphics.Layers;

namespace Core.Graphics
{
    [Serializable()]
    [XmlRoot("TilePainting")]
    public class TilePainting : Image
    {
        public TilePainting()
        {
            //Xml Serialization
        }

        public static TilePainting NewEmptyPainting(int width, int height)
        {
            TilePainting tm = new TilePainting();

            tm.Name = "Empty Painting";
            tm.Width = width;
            tm.Height = height;
            
            //Create Layer set
            tm.Layers = new LayerCollection();
            
            return tm;
        }

        public virtual bool IsTileWalkable(int x, int y)
        {
            if (x < 0 || y < 0)
                return false;

            //TODO: Rebuild Collision System using new GameObject System. For now we will return true for all instances
            return true;
        }

        public virtual Tile GetTileAtLocation(Point local, TileLayer layer)
        {
            return layer.GetTileAtLocation(local.X, local.Y);
        }

        public virtual void SetTileAtLocation(Point local, TileLayer layer, Tile setTile)
        {
            layer.SetTileAtLocation(setTile, local.X, local.Y);
        }
    }
}